﻿using System.Collections.Generic;
using Microsoft.WowAddonStudio.FrameXml.Serialization.LayoutFrames;
using NUnit.Framework;

namespace Microsoft.WowAddonStudio.FrameXml.Serialization.Tests
{
    [TestFixture]
    public class CollectionInheritanceTest
    {
        [Test]
        public void FrameInheritanceTest()
        {
            var masterFrame = new Frame
                                  {
                                      Name = "MasterFrame",
                                      Virtual = true
                                      };

            var editBox = new EditBox { Name = "EditBox" };
            var okButton = new Button { Name = "OKButton", Text = "OK" };

            masterFrame.Frames.Add(editBox);
            masterFrame.Frames.Add(okButton);

            masterFrame.InitializeParent(null, true);

            var childFrame = new Frame
                                 {
                                     Name = "ChildFrame",
                                     Inherits = "MasterFrame"
                                 };

            var cancelButton = new Button { Name = "CancelButton", Text = "Cancel" };

            childFrame.Frames.Add(cancelButton);

            childFrame.InitializeParent(null, true);

            // Assert the parents 
            Assert.AreSame(masterFrame, editBox.ParentFrame);
            Assert.AreSame(masterFrame, okButton.ParentFrame);
            Assert.AreSame(childFrame, cancelButton.ParentFrame);
            
            // Assert the number of controls in the child frame
            Assert.AreEqual(3, childFrame.Frames.Count);
        }
    }
}
